package com.jlcloud.core.context.config;

import com.jlcloud.core.context.JlCloudContext;
import com.jlcloud.core.context.JlCloudHttpHeadersGetter;
import com.jlcloud.core.context.JlCloudServletContext;
import com.jlcloud.core.context.ServletHttpHeadersGetter;
import com.jlcloud.core.context.props.JlCloudContextProperties;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * jlcloud 服务上下文配置
 *
 * @author By: JlCloud <br>
 * @Package: com.jlcloud <br>
 * @CreateTime: 2024-12-03 21:45 <br>
 * @Copyright: 2021 www.jilianjituan.com Inc. All rights reserved. <br>
 * @Caution 注意：本内容仅限于冀联人力集团内部传阅，禁止外泄以及用于其他的商业目的 <br>
 */
@AutoConfiguration
@Order(Ordered.HIGHEST_PRECEDENCE)
@EnableConfigurationProperties(JlCloudContextProperties.class)
public class JlCloudContextAutoConfiguration {

	@Bean
	@ConditionalOnMissingBean
	public JlCloudHttpHeadersGetter jlcloudHttpHeadersGetter(JlCloudContextProperties contextProperties) {
		return new ServletHttpHeadersGetter(contextProperties);
	}

	@Bean
	@ConditionalOnMissingBean
	public JlCloudContext jlcloudContext(JlCloudContextProperties contextProperties, JlCloudHttpHeadersGetter httpHeadersGetter) {
		return new JlCloudServletContext(contextProperties, httpHeadersGetter);
	}

}
